//
//  YZDraggeMoveView.h
//  app
//
//  Created by mac on 2021/7/29.
//

#import <UIKit/UIKit.h>
#define RCDRAGGABLEBUTTON_VERSION @"0.4"

NS_ASSUME_NONNULL_BEGIN

@interface YZDraggeMoveView : UIView {
    BOOL _isDragging;
    BOOL _singleTapCanceled;
    BOOL _skipTapEventOnce;
    BOOL _willBeRemoved;
    BOOL _draggableAfterLongPress;
    BOOL _isRecordingDraggingPathEnabled;
    
    CGPoint _touchBeginPoint;
    CGPoint _moveBeginPoint;
    
    UIBezierPath *_draggingPath;
    
    NSMutableArray *_traceButtons;
    NSTimer *_autoAddTraceButtonTimer;
    NSTimer *_traceDismissTimer;
}
@property (nonatomic) BOOL draggable;
@property (nonatomic) BOOL autoDocking;
@property (nonatomic) BOOL isTraceEnabled;
@property (nonatomic) BOOL dragOutOfBoundsEnabled;

@property (nonatomic) CGPoint dockPoint;
@property (nonatomic) CGFloat limitedDistance;

@property (nonatomic, copy) void(^longPressBlock)(YZDraggeMoveView *button);
@property (nonatomic, copy) void(^longPressEndedBlock)(YZDraggeMoveView *button);

@property (nonatomic, copy) void(^tapBlock)(YZDraggeMoveView *button);
@property (nonatomic, copy) void(^doubleTapBlock)(YZDraggeMoveView *button);

@property (nonatomic, copy) void(^draggingBlock)(YZDraggeMoveView *button);
@property (nonatomic, copy) void(^dragEndedBlock)(YZDraggeMoveView *button);
@property (nonatomic, copy) void(^dragCancelledBlock)(YZDraggeMoveView *button);

@property (nonatomic, copy) void(^autoDockingBlock)(YZDraggeMoveView *button);
@property (nonatomic, copy) void(^autoDockEndedBlock)(YZDraggeMoveView *button);

@property (nonatomic, copy) void(^layerConfigBlock)(YZDraggeMoveView *button);

@property (nonatomic, copy) void(^willBeRemovedBlock)(YZDraggeMoveView *button);

- (id)initInView:(id)view WithFrame:(CGRect)frame;

- (BOOL)isDragging;

+ (NSString *)version;

+ (NSArray *)itemsInView:(id)view;
- (BOOL)isInView:(id)view;

- (BOOL)isInsideRect:(CGRect)rect;
- (BOOL)isIntersectsRect:(CGRect)rect;
- (BOOL)isCrossedRect:(CGRect)rect;

- (void)cleanAllCodeBlocks;

+ (void)removeAllFromView:(id)view;

+ (void)removeFromView:(id)view withTag:(NSInteger)tag;
+ (void)removeFromView:(id)view withTags:(NSArray *)tags;

+ (void)removeAllFromView:(id)view insideRect:(CGRect)rect;
- (void)removeFromSuperviewInsideRect:(CGRect)rect;

+ (void)removeAllFromView:(id)view intersectsRect:(CGRect)rect;
- (void)removeFromSuperviewIntersectsRect:(CGRect)rect;

+ (void)removeAllFromView:(id)view crossedRect:(CGRect)rect;
- (void)removeFromSuperviewCrossedRect:(CGRect)rect;

+ (void)allInView:(id)view moveToPoint:(CGPoint)point animatedWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options completion:(void (^)())completion;
+ (void)inView:(id)view withTag:(NSInteger)tag moveToPoint:(CGPoint)point animatedWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options completion:(void (^)())completion;
+ (void)inView:(id)view withTags:(NSArray *)tags moveToPoint:(CGPoint)point animatedWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options completion:(void (^)())completion;
- (void)moveToPoint:(CGPoint)point animatedWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options completion:(void (^)())completion;

+ (void)allInView:(id)view moveToPoint:(CGPoint)point;
+ (void)inView:(id)view withTag:(NSInteger)tag moveToPoint:(CGPoint)point;
+ (void)inView:(id)view withTags:(NSArray *)tags moveToPoint:(CGPoint)point;
- (void)moveToPoint:(CGPoint)point;

- (CGFloat)distanceFromPoint:(CGPoint)point;

- (CGFloat)distanceFromRect:(CGRect)rect;

- (void)setDraggableAfterLongPress:(BOOL)draggableAfterLongPress;

- (void)startRecordDraggingPath;
- (UIBezierPath *)stopRecordDraggingPath;
- (BOOL)isRecordingDraggingPath;
- (UIBezierPath *)draggingPath;

- (BOOL)checkIfExceedingLimitedDistanceThenFixIt:(BOOL)fixIt;
- (BOOL)checkIfOutOfBoundsThenFixIt:(BOOL)fixIt;
@end

NS_ASSUME_NONNULL_END
